package com.epoch.servicetest.controller;

import bean.response.ResponseBean;
import com.epoch.servicetest.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

/**
 * test controller
 * @author Seven
 * @date 2021/12/1
 */
@RestController
public class TestController {

    @Autowired
    private TestService testService;

    @GetMapping("epoch/test/getTests")
    public ResponseBean getTests(){
        return testService.getTests();
    }

    @GetMapping("epoch/test/getTestsByTypeContent/{typeContent}")
    public ResponseBean getTestsByTypeContent(@PathVariable("typeContent") String typeContent){
        return testService.getTestsByTypeContent(typeContent);
    }

    @GetMapping("epoch/test/getTestByPrimaryId/{id}")
    public ResponseBean getTestByPrimaryId(@PathVariable("id") Integer id){
        return testService.getTestByPrimaryId(id);
    }

    @GetMapping("epoch/test/getExamTestById/{id}")
    public ResponseBean getExamTestById(@PathVariable("id") Integer id){
        return testService.getExamTestById(id);
    }

    @PostMapping("epoch/test/addStuWrong")
    public ResponseBean addStuWrong(@RequestBody HashMap<String , Object> map, HttpServletRequest request){
        return testService.addStuWrong(map, request);
    }

//    @PostMapping("epoch/test/getStuWrongByCsId")
//        public ResponseBean getStuWrongByCsId(@RequestBody HashMap<String,Integer> map){
//        Integer id = map.get("id");
    @GetMapping("epoch/test/getStuWrongByCsId/{id}")
    public ResponseBean getStuWrongByCsId(@PathVariable("id") Integer id){
//        Integer id = map.get("id");
        return testService.getStuWrongByCsId(id);
    }
}
